﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZhiHeng.OneCard.WpfClient.Model
{
   public class QueryTranData:ViewModel.ViewModelBase
    {
       public ZhiHeng.OneCard.CommUtility.TranData Query(string KeyID)
       {
           var e = WcfOneCardActionService.QueryTran(KeyID);
           if (e.Count() < 1)
               return new CommUtility.TranData ();
           var q = e[0];
           ZhiHeng.OneCard.CommUtility.TranData t = new ZhiHeng.OneCard.CommUtility.TranData();
           t.AccountNo = (ushort)q.Account;
           t.AccAmt = q.AccAmt;
           t.DepositAmt = (short)q.EnsureAmt;
           t.Balance = q.CardBalance;
           t.CardNo = (uint)q.CardID;
           t.CardType = BitConverter.GetBytes(q.CardType)[0];
           t.DeptCode = q.DeptCode;
           t.ExpireDate = q.ExpDate;
           t.Flag = q.Flag;
           t.IDCard = q.Identity;
           t.Name = q.Name;
           t.Phone = q.Phone;
           t.SexNo = BitConverter.GetBytes(Convert.ToInt32(q.Sex))[0];
           t.UsedCardNum = (ushort)q.UseCardNum;
           return t;

       }
       public string QueryGuiIdState(string CardId)
       {
           try
           {
               var xx = WcfOneCardActionService.QueryGuiId(CardId);
               if (xx == null)
                   return "未绑定";
               return xx.KeyID != null ? xx.KeyID + "/" + xx.Status : "未绑定";
           }
           catch (Exception ex)
           {
               return "未绑定";
           }
       }
    }
}
